<template>
	<view class="homeLayout pageBg">
		<view class="banner">
			<swiper circular=true indicator-dots=true indicator-color="rgba(255,255,255,0.5)"
				indicator-active-color="#fff" autoplay>
				<swiper-item>
					<image src="/static/images/3.jpg" mode="aspectFill"></image>
				</swiper-item>
				<swiper-item>
					<image src="/static/images/2.jpg" mode="aspectFill"></image>
				</swiper-item>
				<swiper-item>
					<image src="/static/images/1.jpg" mode="aspectFill"></image>
				</swiper-item>
			</swiper>
		</view>
		<view class="notice">
			<view class="left">
				<uni-icons type="sound" size="30" color="#28b389"></uni-icons>
				<text class="text">公告</text>
			</view>
			<view class="center">
				<swiper vertical autoplay interval="1500" duration="300" circular>
					<swiper-item v-for="item in gg">
						<navigator url="/pages/notice/detail">
							{{item}}
						</navigator>
					</swiper-item>
				</swiper>
			</view>
			<view class="right">
				<uni-icons type="right" size="16" color="#333"></uni-icons>
			</view>
		</view>
		<view class="select">
			<common-title>
				<template #name>防诈指南</template>
				<template #more>
					<navigator url="/pages/fzzn/fzzn">
						More+
					</navigator>
				</template>
			</common-title>
			<view class="content">
				<scroll-view scroll-x>
					<view class="box" v-for="item in fzzn">
						<image :src=item mode="aspectFill"></image>
					</view>
				</scroll-view>
			</view>
		</view>
		<view class="query">
			<common-title>
				<template #name>专题精选</template>
				<template #more>
					<navigator url="" class="more">More+</navigator>
				</template>
			</common-title>
			<view class="content">
				<theme-item v-for="(item,index) in items" :key="index" :item="item"></theme-item>
			</view>
		</view>
		<view class="dingshi">
			<navigator url="/pages/remind/remind" class="dingshisrc">
				<image class="pic" mode="aspectFill" src="/static/images/daibantixing.png"></image>
			</navigator>
		</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue';
	// 导入组件
	import CommonTitle from '@/components/common-title/common-title.vue';
	import ThemeItem from '@/components/theme-item/theme-item.vue';
	
	const items = ref([
		{
			navUrl: "/pages/ai/ai",
			srcUrl: "/static/images/ai.jpg",
			name: "AI智能"
		},
	      {
	      	navUrl: "/pages/medicine/medicine",
	      	srcUrl: "/static/images/yongyao.jpg",
	      	name: "用药管家"
	      },
	    
	      {
	      	navUrl: "/pages/notice/detail",
	      	srcUrl: "/static/images/xuexi.jpg",
	      	name: "老年课堂"
	      },
		  {
		  	navUrl: "/pages/notice/detail",
		  	srcUrl: "/static/images/sos.jpg",
		  	name: "急救中心"
		  },
		  {
		  	navUrl: "/pages/body/body",
		  	srcUrl: "/static/images/shenti.jpg",
		  	name: "身体指标"
		  },
		  {
		  	navUrl: "/pages/contacts/contacts",
		  	srcUrl: "/static/images/phone.jpg",
		  	name: "联系人"
		  }
	    ]);
		
		const fzzn = ref([
			"/static/images/11.jpg",
			"/static/images/4.jpg",
			"/static/images/5.jpg",
			"/static/images/6.jpg",
			"/static/images/7.jpg",
			"/static/images/8.jpg",
			"/static/images/9.jpg",
		    ]);
		const gg = ref([
			"健康每一天，快乐常相伴！",
			"保持活力，享受美好生活！",
			"老有所乐，幸福常伴！",
			"珍爱生命，关爱健康！",
			"每天微笑，心态年轻！",
			"老年生活，乐享天年！",
			"生活悠闲，快乐无忧！",
		    ]);	
</script>

<style lang="scss" scoped>
	.dingshi {
		margin-top: 70rpx;
		margin-left: 35rpx;
		margin-right: 35rpx;

		.dingshisrc {
			.pic {
				height: 100rpx;
				width: 650rpx;
			}
		}
	}

	.query {
		margin-top: 50rpx;

		.content {
			margin-top: 30rpx;
			padding: 0rpx 30rpx;
			display: grid;
			gap: 70rpx;
			grid-template-columns: repeat(3, 1fr);
		}

		.more {
			font-size: 32rpx;
		}
	}

	.select {
		padding-top: 10rpx;

		.content {
			width: 720rpx;
			margin-left: 30rpx;
			padding-top: 30rpx;

			scroll-view {
				white-space: nowrap;

				.box {
					width: 200rpx;
					height: 200rpx;
					display: inline-block;
					// margin是男人是外边距 是15
					margin-right: 15rpx;

					image {
						width: 100%;
						height: 100%;
						border-radius: 10rpx;
					}
				}

				// 表示在图片的最后一个显示右侧外边距为30
				.box:last-child {
					margin-right: 30rpx;
				}
			}
		}
	}

	.notice {
		// 页面宽度750 左右两边30 
		width: 690rpx;
		height: 80rpx;
		line-height: 80rpx;
		// 背景颜色
		background: #f9f9f9;
		border-radius: 80rpx;

		margin: 0 30rpx;
		display: flex;

		.left {
			width: 140rpx;
			//  下面这三个就是让局中的
			display: flex;
			align-items: center;
			justify-content: center;

			.text {
				color: #28b389;
				font-weight: 600;
				font-size: 28rpx;
			}
		}

		.center {
			// 两边限制好了,中间适应就好了
			flex: 1;

			swiper {
				height: 100%;

				&-item {
					height: 100%;
					font-size: 30rpx;
					color: #666;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
				}
			}
		}

		.right {
			width: 70rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}

	.homeLayout {
		.banner {
			width: 750rpx;
			padding: 30rpx 0;

			swiper {
				width: 750rpx;
				height: 340rpx;

				// 由于swiper 和swiper-item 是一致的所以可以使用&来代替
				&-item {
					width: 100%;
					height: 100%;
					// 上下左右
					padding: 0 30rpx;

					image {
						width: 100%;
						height: 100%;
						// 设置圆角
						border-radius: 10rpx;
					}
				}
			}
		}
	}
</style>